package sample.test;

import static org.junit.Assert.assertEquals;

import java.util.Arrays;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import sample.code.UserAccess;

/*
 * JUnit - Parameter test sample
 */
@RunWith(Parameterized.class)
public class JunitSample {

	private String user;
	private String pw;
	private boolean expected;

	@Parameters
	public static Collection dataGenerater() {
		return Arrays.asList(new Object[][] { 
				{ "user01", "123456", true },
				{ "helloworld", "123456", false },
				{ "david", "re*ads", false }, 
				{ "goodone", "onegood", true } });
	}

	public JunitSample(String user, String pw, boolean expected) {
		this.user = user;
		this.pw = pw;
		this.expected = expected;
	}

	@Test 
	public void testAccessCheck() {
		assertEquals(expected, UserAccess.accessCheck(user, pw));
	}
}